package com.yue.thread.future;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) {
        FutureTask<String> f = new FutureTask<String>(()->{
            Thread.sleep(3000);
            return "sss";
        });
        new Thread(f).start();
        System.out.println("===");
        // TaskFuture 在get的时候会造成后面的代码阻塞
        try {
            System.out.println(f.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }
}
